package com.nuanshui.heatedloan.task.logging.logback;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;

import ch.qos.logback.classic.LoggerContext;

import com.nuanshui.heatedloan.middleware.rabbitmq.RabbitmqMessageSender;
import com.nuanshui.heatedloan.task.logging.LogAdapter;

/**
 * logback日志适配器
 * @param 
 * @author guohao
 * @date 2017年2月13日 上午9:50:24
 * @since $
 */
public class LogbackAdapter  implements LogAdapter{

	@Override
	public void start(BeanFactory beanFactory) {
		
		LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();  	 
		JobInfoLoggerAppender loggerAppenderTest = new JobInfoLoggerAppender(beanFactory.getBean(RabbitmqMessageSender.class));
		loggerAppenderTest.setContext(loggerContext);  
		ch.qos.logback.classic.Logger   rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
		rootLogger.addAppender(loggerAppenderTest);
		loggerAppenderTest.start();
		
	}

}
